package model.entity;

import java.util.ArrayList;
import java.util.List;

import model.entity.stats.StatSet;
import model.item.EquipmentType;
import model.skill.ActivateableSkill;
import model.skill.NonactivateableSkill;
import model.skill.Skill;
import utilities.*;

/**
 * 
 * Occupations contains anything that relates and
 * things that are affected by occupations.
 *
 */

public class Occupation	implements Archiveable {


	private String occupationType;
	private StatSet levelUpStats;
	private List<String> canEquip;
	private List<Skill> allowableSkills;
	private List<ActivateableSkill> currentActivateableSkills;
	private List<NonactivateableSkill> currentNonActivateableSkills;

	public Occupation( String occupationType, StatSet levelUpStats, List<String> canEquip, 
			List<Skill> allowableSkills, List<ActivateableSkill> currentActivateableSkills, 
			List<NonactivateableSkill> currentNonActivateableSkills){

		this.occupationType = occupationType;
		this.levelUpStats = levelUpStats;
		this.canEquip = canEquip;
		this.allowableSkills = allowableSkills;
		this.currentActivateableSkills = currentActivateableSkills;
		this.currentNonActivateableSkills = currentNonActivateableSkills;

	}
	
	public Occupation() {
		occupationType = "SMASHER";
		canEquip = new ArrayList<String>();
		allowableSkills = new ArrayList<Skill>();
		currentActivateableSkills = new ArrayList<ActivateableSkill>();
		currentNonActivateableSkills = new ArrayList<NonactivateableSkill>();
	}
	
	public String getOccupationType()
	{
		return occupationType;
	}

	public StatSet getLevelUpStats()
	{
		return levelUpStats;
	}

	public List<String> getCanEquip()
	{
		return canEquip;
	}

	public List<Skill> getAllowableSkills()
	{
		return allowableSkills;
	}

	public List<ActivateableSkill> getCurrentActivateableSkills()
	{
		return currentActivateableSkills;
	}

	public List<NonactivateableSkill> getCurrentNonActivateableSkills()
	{
		return currentNonActivateableSkills;
	} 
	public void addNonActivateableSkill(NonactivateableSkill skill) {
		currentNonActivateableSkills.add(skill);
	}
	//TODO BAD FIX THIS SOMEHOW
	public ActivateableSkill getActivateableSkill(String skillName)
	{
		for (ActivateableSkill a : currentActivateableSkills) {
			if (a.getName().equalsIgnoreCase(skillName)) return a;
		}
		return null;
	}
	
	public NonactivateableSkill getNonActivateableSkill(String skillType)
	{
		NonactivateableSkill skill = null;
		for (NonactivateableSkill a : currentNonActivateableSkills) {
			if (a.getSkillType().equalsIgnoreCase(skillType)) skill = a; break;
		}
		return skill;
	}
	
	public Archive save() {
		Archive archive = ArchiveFactory.createArchive();
		
//		archive.putAttribute("occupationType", this.occupationType);
//		
//		archive.putClassName("levelUpStats", this.levelUpStats.getClass().getName());
//		archive.putOneRelationship("levelUpStats", this.levelUpStats);
		
		return archive;
	}
	
	public void load(Archive archive) {
//		this.occupationType = archive.getAttribute("occupationType");
//		
//		this.levelUpStats = (StatSet)ModelFactory.getInstance().createInstanceWithClassName(archive.getClassName("levelUpStats"));
//		this.levelUpStats.load(archive.getOneRelationship("levelUpStats"));
	}
	
}

